@extends('base')

@section('content')
    <div class="layui-card">
        <div class="layui-card-body">
            <form action="{{route('caiwu.contract.store')}}" method="post" class="layui-form">
                {{csrf_field()}}
                <div class="layui-form-item">
                    <label for="" class="layui-form-label">选择客户</label>
                    <div class="layui-input-inline" style="width: 90px">
                        <button type="button" id="chose_customer" class="layui-btn layui-btn-sm">点击选择</button>
                    </div>
                    <input type="hidden" name="customer_id" value="0" id="customer_id">
                    <div class="layui-word-aux layui-form-mid" id="customer_tips"></div>
                </div>
                <div class="layui-form-item">
                    <label for="" class="layui-form-label">开始日期</label>
                    <div class="layui-input-block">
                        <input class="layui-input" type="text" name="stime" id="stime" lay-verify="required" placeholder="点击选择" readonly>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="" class="layui-form-label">结束日期</label>
                    <div class="layui-input-block">
                        <input class="layui-input" type="text" name="etime" id="etime" lay-verify="required" placeholder="点击选择" readonly>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="" class="layui-form-label">合同金额</label>
                    <div class="layui-input-block">
                        <input class="layui-input" id="total_money" type="number" name="total_money" lay-verify="required" placeholder="合同总金额">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="" class="layui-form-label">已收款</label>
                    <div class="layui-input-block">
                        <input class="layui-input" type="number" name="payed_money" value="0" lay-verify="required" placeholder="已收款总金额">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="" class="layui-form-label">备注</label>
                    <div class="layui-input-block">
                        <textarea name="remark" class="layui-textarea" lay-verify="required" ></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="" class="layui-form-label">附件</label>
                    <div class="layui-input-block">
                        @include('common.multiple_file')
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="button" class="layui-btn layui-btn-sm" lay-submit lay-filter="go-close-refresh" >确认</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
@endsection

@section('script')
    <script>
        layui.use(['element', 'form', 'layer', 'table', 'upload', 'laydate', 'jquery'], function () {
            var $ = layui.jquery;
            var form = layui.form;
            var table = layui.table;
            var layer = layui.layer;
            var laydate = layui.laydate;

            $("#chose_customer").click(function () {
                layer.open({
                    type: 2,
                    title: false,
                    shadeClose: true,
                    area: ["80%","80%"],
                    content: '{{route('api.choseCustomer')}}',
                })
            })

            laydate.render({
                elem: '#stime',
                type: 'date'
            });
            laydate.render({
                elem: '#etime',
                type: 'date'
            });

        });
    </script>
@endsection
